
<script type="text/javascript">
	
	$(document).ready(function() {
		 $('#anggaran').submit(function() { 
			
			$.ajax({
				type: 'POST',
				url: "<?=base_url().'index.php/anggaran/view_posting_anggaran/'?>",
				data: $('#anggaran').serialize(),
				success: function(data) {
					$.fancybox(data, {
						'width' : 440,
						'height': 500
					  });
				}
			});
			return false;		
		}); 
		
		$("#getakun").fancybox();
		get_total_kas();
	});
	
	function set_detail(){		
		if(document.getElementById('detail_akunid').value == ''){

			alert('Isi nama barang terlebih dahulu.');

		}else{

			$.ajax({

				type: 'POST',

				url: '<?=base_url().'asset/admin/js/ajax_anggaran.php?command=add_1'?>',

				data: $('#anggaran').serialize(),

				success: function(data) {

					$('#detail').html(data);

				}

			});

			

			document.getElementById('detail_akunid').value = '';	
			document.getElementById('detail_nakun').value = '';
			document.getElementById('detail_jumlah').value = '';
			document.getElementById('detail_count').value = '';

		}

	}
	
	function save_data(){
		var isi = document.getElementById('detail').innerHTML;
		if( isi == false){
			document.getElementById('alert_yanto').innerHTML = '<ul class="message error grid_12"><li>List data barang tidak boleh kosong</li><li class="close-bt"></li></ul><br>';

			alert('kosong');

			$('html, body').stop().animate({

				scrollTop: 0 //$($anchor.attr('href')).offset().top

			}, 700, 'easeInOutExpo');

		}else{

			document.getElementById('alert_yanto').innerHTML = '';
			alert('berisi');
			document.forms["anggaran"].submit();
		}

		

	}
	
	
	function remove_detail(id){

		$.ajax({

			type: 'POST',

			url: '<?=base_url().'asset/admin/js/ajax_anggaran.php?command=remove&id='?>'+id,

			data: $('#anggaran').serialize(),

			success: function(data) {

				$('#detail').html(data);

			}

		});
	}
	
	function batal(){
		document.location.href = '<?=base_url().'index.php/anggaran'?>';
	}
	$(function(){

		$("#tanggal").datepicker({dateFormat: 'yy-mm-dd', yearRange: '2001:2021' });

	})
	function klick_tanggal(){

		var tanggal = document.getElementById("tanggal");

		tanggal.focus();

	}
	function get_total_kas(){
		var getselect=document.getElementById('kd_kas').value;
		load("anggaran/get_kas/" + getselect ,"jumlah_kredit");	
		
	}
	
</script>

	<?php 
		if(validation_errors())
		{
	?>
			<ul class="message error grid_12">
				<li><?=validation_errors()?></li>
				<li class="close-bt"></li>
			</ul>	
	<?php
		} 
	?>
	
	
<div id="page-heading"><h1>Anggaran >> Import Data Anggaran</h1></div>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
	<th rowspan="3" class="sized"><img src="<?php echo base_url() ?>asset/admin/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
	<th class="topleft"></th>
	<td id="tbl-border-top">&nbsp;</td>
	<th class="topright"></th>
	<th rowspan="3" class="sized"><img src="<?php echo base_url() ?>asset/admin/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
</tr>
<tr>
	<td id="tbl-border-left"></td>
	<td>
		<!--  start content-table-inner -->
		<div id="content-table-inner">
		<div id="table-content">
		<table border="0" width="100%" cellpadding="0" cellspacing="0">
		<tr valign="top">
			<td>
			
			
			<!--  start step-holder -->
			<div id="step-holder">
						<div class="step-no">1</div>
						<div class="step-light-left">
							<?php 
								echo anchor('anggaran/index', 'Daftar File Upload');
							?>
						</div>
						<div class="step-light-right">&nbsp;</div>
						<div class="step-no">2</div>
						<div class="step-dark-left">
							<?php  
								echo anchor('anggaran/add', 'Import Data Anggaran');
						?>
						</div>
						<div class="step-dark-right">&nbsp;</div>
						<div class="step-no">3</div>
						<div class="step-light-left">
							<?php 
								$now = date('m')-1;
								$now2 = '1-'.$now.'-'.date('Y');
								$now3 = '31-'.$now.'-'.date('Y');
								echo anchor('anggaran/verifikasi', 'Daftar Data Anggaran');
						?>
						</div>
						<div class="step-light-right">&nbsp;</div>
						<div class="step-no">4</div>
						<div class="step-light-left">
							<?php
								echo anchor('anggaran/report', 'Ekspor Data');
							?>
						</div>
						<div class="step-light-round">&nbsp;</div>
											
						<div class="clear"></div>
					</div>
			<!--  end step-holder -->
		
		
		
		
		
			<!-- start id-form -->
			<table border="0" cellpadding="0" cellspacing="0"  id="id-form">
			<?php 
			$attributes = array('name' => 'form1', 'id' => 'form1', 'class'=>'block-content form');
			echo form_open_multipart('anggaran/insert', $attributes);
			?>
			<tr>
				<th valign="top"></th>
				<td>	
					<br/><br/>
				</td> 
			</tr>
		<script>
			function cek_tahun(){
				$("#pesan").hide();
				var tahun = $("#tahun").val();
				if(tahun != ""){
					$.ajax({
						url: "<?php echo site_url() . '/anggaran/cek_tahun'; ?>", //arahkan pada proses_tambah di controller member
						data: 'tahun='+tahun,
						type: "POST",
						success: function(msg){
							if(msg==1){
								$("#pesan").css("color","#fc5d32");
								$("#tahun").css("border-color","#fc5d32");
								$("#pesan").html("Anggaran tahun " + tahun + " sudah tersedia.");
								error = 1;
							}else{
								$("#pesan").css("color","#59c113");
								$("#tahun").css("border-color","#59c113");
								$("#pesan").html("Anggaran tahun " + tahun + " belum tersedia.");
								error = 0;
							}
							$("#pesan").fadeIn(1000);
						}
					});
				}   
			}

		function post() {
		var tahun = $("#tahun").val();
		if(error==1){
								if (confirm('Apakah anda akan menghapus anggaran tahun '+tahun+ ' dan menggantinya dengan data ini?')){
									form1.action="<?php echo site_url() . '/anggaran/insert'; ?>";
									form1.submit(); //to delete the records
								  } 
							}else{ 
									form1.action="<?php echo site_url() . '/anggaran/insert'; ?>";
									form1.submit(); //to delete the records
								  
								//var error2 = false;
							} 
		
		}		
		</script>
		 
			<tr>
				<th valign="top">Tahun (*) :</th>
				<td>	

				<select name="tahun" id="tahun" onchange='cek_tahun()'>
					<option value='' selected>Pilih Tahun</option>
					
					<?
						//echo "<option value= ' ' selected>Pilih Tahun</option>";
						$y =  date('Y');
						for ($i=$y+10; $i>=$y-2; $i--)
						{
							//$sel = ($i == date('Y'))? "selected" : "";
							//echo "<option value=\"".$i."\" $sel>".$i."</option>";
							echo "<option value=\"".$i."\" >".$i."</option>";
						}
					?>
				</select>

					<span id='pesan'></span>
				</td> 	
			</tr>   

			<tr>
				<th valign="top">Uraian (*) :</th>
				<td>	
					<input type="text" name="uraian" id="uraian" value="<?=set_value('uraian')?>" > 
				</td> 
			</tr>
			<tr>
				<th valign="top">Pilih File (*) :<br/>Jenis File (excel 2003)</th>
				<td class="noheight">
					<input name="userfile" id="userfile" type="file" value=""  size="42"/>
				</td>
			</tr>
			<tr>
				<th valign="top"></th>
				<td>	
					<br/>
				</td> 
			</tr>
			<tr>
				<th valign="middle"></th>
				<td class="noheight">
				 
					<!--<button type="submit"><img src="<?=base_url()?>asset/admin/images/icons/fugue/tick-circle.png" width="16" height="16"> Upload</button>
					<button type="button" onclick="javascript:batal();" class="red">Batal</button> 	
					-->
					<input type="submit" value="Upload" class="form-submit" onclick="javascript:post();"/>
					<input type="reset" value="Batal" class="form-reset" onclick="javascript:batal();" />
				</td>	
			</tr>
			<tr>
				<th valign="top" color="#ff0000">(*)Harus diisi<br/></th>
				<td>	
									<br/><br/>
				</td> 
			</tr>
			</form>
			</table>
			<!-- end id-form  -->
			 
			 
			 
		 
			
			
			</td>
		</tr>
		</table>
		 
	<div class="clear"></div>
 
</div>
	</div>	
	</td>
	<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>
 


			